{% extends 'myadmin/base.html' %}

{% block main_body %}
<div style="height:60px">

</div>
 <div class="card-header">
     <h3 class="card-title"><a href="{% url 'myadmin_index' %}">首页</a> >> <a href="{% url 'myadmin_image_index' %}">镜像管理</a> >> 镜像编辑 </h3>
 </div>
<div style="width:70%; margin-left:15%;">
 <div class="card card-primary">
              <div class="card-header">
                <h3 class="card-title">镜像编辑</h3>
              </div>
              <!-- /.card-header -->
              <!-- form start -->
              <form action="{% url 'myadmin_image_update' %}" method="post">
                  {% csrf_token %}
                <div class="card-body">
                  <div class="form-group">
                      <label for="imagename">镜像名称<font color="red">*</font></label>
                      <p><font color="red"><b>{{ flavor.name }}</b></font> </p>
                      <input type="hidden" name="imageid" value="{{ image.id }}" />
                      <input type="text" name="imagename" value="{{ image.name }}" />
                  </div>
                  <div class="form-group">
                    <label for="imagediskformat">镜像格式<font color="red"></font></label>
                    <input type="text" class="form-control" id="imagediskformat" name="imagediskformat"  value="{{ image.disk_format }}" disabled="false">
                  </div>
                      <div class="form-group">
                    <label for="imagesize">镜像大小<font color="red"></font></label>
                    <input type="text" class="form-control" id="imagesize" name="imagesize"  value="{% widthratio image.size|floatformat:2  1048576 1  %}MB" disabled="false">
                  </div>
                    <div class="form-group">
                    <label for="mindisk">最小磁盘(GB)<font color="red"></font></label>
                    <input type="text" class="form-control" id="ram" name="mindisk"  placeholder="请输入最小磁盘" value="{{ image.min_disk }}" disabled="false">
                  </div>
                    <div class="form-group">
                    <label for="minram">最低内存(MB)<font color="red"></font></label>
                    <input type="text" class="form-control" id="minram" name="minram" placeholder="请输入最低内存" value="{{ image.min_ram }}" disabled="false">
                  </div>
                     <div class="form-group">
                    <label for="protected">受保护的</label>
                          {%  if  image.protected == True  %}
                                 <input type="radio" name="ragrp1" value="0" > 不
                                 <input type="radio" name="ragrp1"  value="1" checked> 是
                          {% else %}
                                <input type="radio" name="ragrp1" value="0" checked> 不
                                <input type="radio" name="ragrp1" value="1"> 是
                         {% endif %}
                  </div>


                </div>
                <!-- /.card-body -->

                <div class="card-footer">
                  <button type="submit" class="btn btn-primary" onclick="return check();">修改</button>
                    &nbsp; &nbsp;
                    <button type="reset" class="btn btn-primary">重置</button>
                </div>
              </form>
            </div>
</div>
<script>
    function check(){
         flavorname = document.getElementById('flavorname').value;
         info="";

         if(flavorname==""){
            info="镜像名称不能为空！！\n"
         }

         if(info!=""){
            alert(info);
            return false;
         }

         return true;

    }
</script>

{% endblock %}